﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace IYAA_BBS_SPIDER
{
    public class XmlHelper
    {
        public XmlHelper()
        { }

        public static void EditXmlAttr(string path,string node,string attr,string oldValue,string newValue)
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(path);
            XmlNode xn = xmlDoc.SelectSingleNode(node);
            XmlNodeList xnl = xn.ChildNodes;
            foreach (XmlNode xnf in xnl)
            {
                XmlElement xe = (XmlElement)xnf;
                if (xe.GetAttribute(attr) == oldValue)
                {
                    xe.SetAttribute(attr, newValue);
                }
            }
            xmlDoc.Save(path);
        }



    }
}
